Cube Yogi
Cube Yogi
Leader in AI, Drone, Robotics & Digitization

Restrict Employee From Taking Multiple Days Of Leave

Here is our approach for Restricting Employees from taking mutiple days of leave in Zoho People in a few simple steps.

Even a non-technical person can easily set it up in just a few steps.


                                                                                                                  

                                                   Approach   


We can create and assign employee shifts in Zoho People using the following steps

1. Navigate to Settings and Create Custom Function

1.1 Goto "Settings"

1.2 Click "Leave Tracker" Under Settings

1.3 Click "Automation" under Leave Tracker

1.4 Click ">" before Actions

1.5 Click "Custom Function" under Actions

1.6 Click "Add Custom Function"

2. Configure And Setup Function 

2.1 Provide "Function Name"

2.2 Click "Edit Parameters"

2.4 Provide "Method Name"

2.5 Provide "Argument Name" to use it on Function

2.6 Click "Seacrh" before Enter value

2.7 Click On "ID"

3. Enable Zoho People connection And Provide Scopes

3.1 Click on "Connections"

3.2 Click "Create Connection"

3.3 Click "Search" 🔍 

3.4 Enter Zoho People

3.5 Provide "Connection Name"

3.6 Define Scope

3.5 Click "Create And Connect"

Here is the updated custom function script to calculate festival days and automatically cancel overlapping leave requests:

toDate = leaveRecord.get("To").toDate();
festivalStart = "2026-11-08".toDate();
festivalEnd = "2026-11-12".toDate();
festivalDaysCount = 0;
currentCheckDate = fromDate;
for each  day in {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30}
{
	if(currentCheckDate <= toDate)
	{
		if(currentCheckDate >= festivalStart && currentCheckDate <= festivalEnd)
		{
			festivalDaysCount = festivalDaysCount + 1;
		}
		currentCheckDate = currentCheckDate.addDay(1);
	}
}
info "From Date = " + fromDate;
info "To Date = " + toDate;
info "Festival Days Count = " + festivalDaysCount;
cancelResponse = invokeurl
[
	url :"https://people.zoho.in/people/api/v3/leave-tracker/leaves/" + leaveId
	type :PATCH
	parameters:{"reason":"Test cancellation - Festival Leave Policy"}
	connection:"peoplecf"
];
info cancelResponse;
return "success";